package com.rightrule.rule.constans;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

public enum ScriptTypeEnum {

    Aviator(0),
    /**
     * groovy脚本
     */
    Groovy(1),

    /**
     * 评分卡
     */
    ScoreCard(3);


    ScriptTypeEnum(Integer code) {
        this.code = code;
    }

    public Integer getCode() {
        return code;
    }

    private Integer code;


    public static Optional<ScriptTypeEnum> of(Integer code) {
        if (code == null) {
            return Optional.empty();
        }

        return Arrays.stream(values()).filter(scriptTypeEnum -> Objects.equals(scriptTypeEnum.getCode(), code)).findFirst();
    }
}
